#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    /*
        1.菜单栏：可以偷懒在ui设计师中直接添加菜单项和子菜单项
        2.工具栏：需要自己手写代码添加你想要的组件
             QAction *QToolBar::addWidget(QWidget *widget)
    */
    //工具栏添加你想要的各种组件
    QPushButton *bt=new QPushButton(QIcon("C:/Users/Administrator/Desktop/share/image/cachu.jpg"),"");
    connect(bt,SIGNAL(clicked()),this,SLOT(fun()));
    ui->toolBar->addWidget(bt);

    QLineEdit *lineedit=new QLineEdit();
    ui->toolBar->addWidget(lineedit);

    //创建下拉框
    QComboBox *combox=new QComboBox();
    //给下拉框添加文本内容
    combox->addItem("经典模式");
    combox->addItem("复古模式");
    combox->addItem("现代模式");
    combox->addItem("科幻模式");
    ui->toolBar->addWidget(combox);

}

MainWindow::~MainWindow()
{
    delete ui;
}

//你点击了新建子菜单
void MainWindow::on_actionxinjian_triggered()
{
    qDebug()<<"你点击了新建";
}

void MainWindow::on_actiondakai_triggered()
{
    qDebug()<<"你点击了打开";
}

void MainWindow::on_actionbaocun_triggered()
{
    qDebug()<<"你点击了保存";
}
//工具栏中添加的那个按钮对应的槽函数
void MainWindow::fun()
{
    qDebug()<<"工具栏添加的按钮被点击了";
}
